package com.ihealthway.all.interfaces.dwihealth.vo;

import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Name;
import org.nutz.dao.entity.annotation.PK;
import org.nutz.dao.entity.annotation.Table;
import org.nutz.lang.Strings;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import java.util.Date;

/**
 * Bean class for DW service plan item design
 * @author 凡梦星尘(elkan1788@gmail.com)
 */
@Table("interf_dw_serplan_item")
@PK({"serPlanId", "serItemNo"})
@XmlRootElement
@XmlType(propOrder = { "serItemNo", "serItemName", "prePersonTimes" })
public class DWSerPlanItem {

    @Column("serplan_id")
    private String serPlanId;
    @Column("seritem_no")
    private String serItemNo;
    @Column("seritem_name")
    private String serItemName;
    @Column("pre_person_times")
    private Integer prePersonTimes;

    @Column("create_time")
    private Date createTime;
    @Column("update_time")
    private Date updateTime;
    @Column("data_status")
    private String dataStatus;

    @XmlTransient
    public String getSerPlanId() {
        return serPlanId;
    }

    public void setSerPlanId(String serPlanId) {
        this.serPlanId = serPlanId;
    }

    @XmlElement(name = "ServItemNo")
    public String getSerItemNo() {
        return serItemNo;
    }

    public void setSerItemNo(String serItemNo) {
        this.serItemNo = serItemNo;
    }

    @XmlElement(name = "ServItemName")
    public String getSerItemName() {
        return serItemName;
    }

    public void setSerItemName(String serItemName) {
        this.serItemName = serItemName;
    }

    @XmlElement(name = "PrePersonTimes")
    public Integer getPrePersonTimes() {
        return prePersonTimes;
    }

    public void setPrePersonTimes(Integer prePersonTimes) {
        this.prePersonTimes = prePersonTimes;
    }

    @XmlTransient
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @XmlTransient
    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    @XmlTransient
    public String getDataStatus() {
        return dataStatus;
    }

    public void setDataStatus(String dataStatus) {
        this.dataStatus = dataStatus;
    }

    public ErrorInfoElement valid(String serPlanNo) {
        ErrorInfoElement error = new ErrorInfoElement();

        error.setServPlanNo(serPlanNo);
        error.setServItemNo(this.serItemNo);

        if (Strings.isBlank(this.serItemNo)) {
            error.setErrorInfo("服务项目编码不能为空");
            return error;
        }

        if (Strings.isBlank(this.serItemName)) {
            error.setErrorInfo("服务项目名称不能为空");
            return error;
        }

        this.serPlanId = serPlanNo;
        this.dataStatus = "1";
        this.createTime = new Date();

        return null;
    }

    @Override
    public String toString() {
        return "DWSerPlanItem{" +
                "serPlanId='" + serPlanId + '\'' +
                ", serItemNo='" + serItemNo + '\'' +
                ", serItemName='" + serItemName + '\'' +
                ", prePersonTimes=" + prePersonTimes +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", dataStatus='" + dataStatus + '\'' +
                '}';
    }
}
